﻿/// <reference path="../../../Scripts/jquery-1.5.2.js" />
/// <reference path="../../../Scripts/jquery.validate.js" />
/// <reference path="../../../Scripts/jquery/jquery.message.js" />
/// <reference path="../../../Scripts/jquery/jquery.form.js" />

$(document).ready(function ()
{
    $(".userInput").validate(
    {
        submitHandler: function (form)
        {
            var _msg = $(form).find(".msg");

            $.ajax(
            {
                type: "POST",
                data: $(form).form(),
                error: function ()
                {
                    $.message.create({ msg: "系统错误 ! 请稍候重试", to: _msg, timer: 3000 });
                },
                success: function (message)
                {
                    if (message && message.flag)
                        window.location = $.mvc.action("welcome", "usercenter");
                    else
                        $.message.create({ msg: message.msg, to: _msg, timer: 5000 });
                }
            });
        }
    });
});